import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RankVO, RankForm, RankQuery } from '@/api/stroke/rank/types';

/**
 * 查询积分排名列表
 * @param query
 * @returns {*}
 */

export const listRank = (query?: RankQuery): AxiosPromise<RankVO[]> => {
  return request({
    url: '/stroke/rank/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询积分排名详细
 * @param id
 */
export const getRank = (id: string | number): AxiosPromise<RankVO> => {
  return request({
    url: '/stroke/rank/' + id,
    method: 'get'
  });
};

/**
 * 新增积分排名
 * @param data
 */
export const addRank = (data: RankForm) => {
  return request({
    url: '/stroke/rank',
    method: 'post',
    data: data
  });
};

/**
 * 修改积分排名
 * @param data
 */
export const updateRank = (data: RankForm) => {
  return request({
    url: '/stroke/rank',
    method: 'put',
    data: data
  });
};

/**
 * 删除积分排名
 * @param id
 */
export const delRank = (id: string | number | Array<string | number>) => {
  return request({
    url: '/stroke/rank/' + id,
    method: 'delete'
  });
};
